package com.rawchen.controller;

import com.rawchen.annotation.VisitLogger;
import com.rawchen.model.vo.Result;
import com.rawchen.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Description: 归档页面
 */
@RestController
public class ArchiveController {
	@Autowired
	private BlogService blogService;

	/**
	 * 统计公开博客总数，按年月分组归档公开博客
	 */
	@VisitLogger(behavior = "访问页面", content = "文章归档")
	@GetMapping("/archives")
	public Result archives() {
		Map<String, Object> archiveBlogMap = blogService.getArchiveBlogAndCountByIsPublished();
		return Result.ok("请求成功", archiveBlogMap);
	}
}
